<?php
/**
 * @Author:      lyt
 * @DateTime:  2017-05-03 18:18:45
 * @Description: Description
 */
class DrivingLicense extends Eloquent
{
    protected $table = "driving_license";

    public static function record($user_id,$id,$car_no ='',$car_type='',$own='',$address='',$model='',$vin='',$engine_number='',$register_time='',$send_time='',$use_nature=''){
        $data = DrivingLicense::where('id',$id)->first();
        if(!is_null($data)){
            if($car_no != '') $data->car_no = $car_no;
            if($car_type != '') $data->car_type = $car_type;
            if($own != '') $data->own = $own;
            if($address != '') $data->address = $address;
            if($model != '') $data->model = $model;
            if($vin != '') $data->vin = $vin;
            if($engine_number != '') $data->engine_number = $engine_number;
            if($register_time != '') $data->register_time = $register_time;
            if($send_time != '') $data->send_time = $send_time;
            if($use_nature != '') $data->use_nature = $use_nature;

            UserDrivingLicense::insert(
                array(
                    'user_id' => $user_id,
                    'car_no' => $data->car_no,
                    'car_type' => $data->car_type,
                    'own' => $data->own,
                    'address' => $data->address,
                    'model' => $data->model,
                    'vin' => $data->vin,
                    'engine_number' => $data->engine_number,
                    'register_time' => $data->register_time,
                    'send_time' => $data->send_time,
                    'use_nature' => $data->use_nature,
                    'img' => $data->img,
                )
            );
        }
    }
}